import request from '../utils/request';

/**
 * 智能导入API
 * 支持表头自动匹配的Excel批量导入
 */
export const dynamicImportApi = {
  // 员工导入
  importEmployee: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/employee', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  importEmployeeWithUpdate: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/employee-update', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  getEmployeeImportHelp: () => {
    return request.get('/api/dynamic-import/employee/help');
  },

  // 项目导入
  importProject: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/project', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  importProjectWithUpdate: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/project-update', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  getProjectImportHelp: () => {
    return request.get('/api/dynamic-import/project/help');
  },

  // 合同人员导入
  importContractPersonnel: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/contract-personnel', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  importContractPersonnelWithUpdate: (file) => {
    const formData = new FormData();
    formData.append('file', file);
    return request.post('/api/dynamic-import/contract-personnel-update', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    });
  },

  getContractPersonnelImportHelp: () => {
    return request.get('/api/dynamic-import/contract-personnel/help');
  }
};

